package com.kgc.controller;


import com.kgc.service.IOutOrderProviderService;
import entity.ResponseMessage;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import service.order.OutOrderAPI;

import java.util.Date;

/**
 * @description:
 * @author: Cheng
 * @create: 2022-04-20 11:11
 **/
@Controller
//@RequestMapping("OutOrder")
public class OutOrderProviderController  implements OutOrderAPI {


    private Logger logger = Logger.getLogger(this.getClass());

    @Autowired
    private IOutOrderProviderService iOutOrderProviderService;

    /**
     * 按条件查询门店订单信息
     * @param orderNum
     * @param sname
     * @param startTime
     * @param endTime
     * @param status
     * @param pageNum
     * @return
     */
    @Override
    @RequestMapping("selectOutOrderInfo")
    @ResponseBody
    public ResponseMessage selectOutOrderInfo(@RequestParam(value = "orderNum",required = false) String orderNum,
                                              @RequestParam(value = "sname",required = false) String sname,
                                              @RequestParam(value = "startTime",required = false) Date startTime,
                                              @RequestParam(value = "endTime",required = false) Date endTime,
                                              @RequestParam(value = "status",required = false,defaultValue = "-1") int status,
                                              @RequestParam(value = "pageNum",required = false,defaultValue = "1") int pageNum
    ) {
        logger.info("OutOrderProviderController selectOutOrderInfo is start ... params:orderNum:-->" + orderNum + ",sname:-->" + sname + ",startTime:-->" + startTime + ",endTime:-?" + endTime + ",status:->" + status + ",pageNum:->" + pageNum);
        ResponseMessage responseMessage = iOutOrderProviderService.selectOutOrderInfo(orderNum, sname, startTime, endTime, status, pageNum);
        logger.debug("OutOrderProviderController selectOutOrderInfo result:" + responseMessage);
        return responseMessage;
    }


    /**
     * 通过OutOrderInfo的id查询    联表 product
     * @param id
     * @return ResponseMessage
     */
    @Override
    @RequestMapping("selectProductAndOutOrderInfo")
    @ResponseBody
    public ResponseMessage selectProductAndOutOrderInfo(@RequestParam("id") String id) {
        logger.info("OutOrderProviderController selectProductAndOutOrderInfo is start...param:id-->" + id);
        ResponseMessage responseMessage = iOutOrderProviderService.selectProductAndOutOrderInfo(id);
        logger.debug("OutOrderProviderController selectProductAndOutOrderInfo result:" + responseMessage);
        return responseMessage;
    }
}
